<?xml version="1.0" encoding="UTF-8"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui" template="/masterPage.xhtml">
	<ui:define name="content">
		<h:form id="publisherss_list_form">
			<p:growl id="messages" showDetail="true" sticky="true" />

			<p:toolbar id="toolbar"   style="margin-top:20px; margin-bottom:5px">
				<p:toolbarGroup align="left">
					<p:commandButton value="Create"
						actionListener="#{publisherBean.showCreateDialog}" style="font-size: 85% !important" />
				</p:toolbarGroup>

			</p:toolbar>
			<p:dataTable id="PublishersTable" var="publ"
				value="#{publisherBean.publishers}" rowKey="#{publ.id}"
				selection="#{publisherBean.selectedPublisher}"
				selectionMode="single">
				<p:column id="publisher_id" headerText="ID" sortBy="#{publ.id}">
					<h:outputText value="#{publ.id}" />
				</p:column>
				<p:column id="publisher_name" headerText="Name">
					<h:outputText value="#{publ.name}" />
				</p:column>
				<p:column id="publisher_website" headerText="Website">
					<h:outputText value="#{publ.website}" />
				</p:column>
			</p:dataTable>

		</h:form>

		<h:form id="createdlg_form">

			<p:dialog id="createdlg" header="Create Dialog" widgetVar="createdlg"
				modal="true">
                 <ui:include src="dialogs/newPublisherDialog.xhtml" />
			</p:dialog>

            <script type="text/javascript">
                function handleCreatePublisherRequest(xhr, status, args) {
                    if(args.validationFailed || !args.savePublisher) {
                        jQuery('#createdlg').effect("shake", { times:3 }, 100);
                    } else {
                        createdlg.hide();
                    }
                }
            </script>
		</h:form>


	</ui:define>
</ui:composition>